<!-- header -->
<template>
  <div class="header-container" ref="header">
    <div class="content-wrapper">
      <img :src="seller.avatar"  class="avatar">
      <div class="content">
        <div class="title">
          <span class="brand"></span>
          <span class="name">{{seller.name}}</span>
        </div>
        <div class="description">
          {{seller.description}}/{{seller.deliveryTime}}分钟送达
        </div>
        <div class="support" v-if="seller.supports">
          <span class="icon" :class="classMap[seller.supports[0].type]"></span>
          <span class="text">{{seller.supports[0].description}}</span>
        </div>
      </div>
      <div class="support-count" v-if="seller.supports" @click="openDetail">
        <span>{{ seller.supports.length }}个</span>
        <i class="icon-keyboard_arrow_right"></i>
      </div>
    </div>
    <!-- 公告区域 -->
    <div class="bulletin">
      <span class="bulletin-icon"></span><span class="bulletin-description">{{seller.bulletin}}</span>
      <i class="icon-keyboard_arrow_right" @click="openDetail"></i>
    </div>
    <!-- 模糊背景区域 -->
    <div class="background" >
      <img :src="seller.avatar" alt="">
    </div>
    <!-- 弹出detail区域 -->
      <mt-popup v-model="popupflag" position="bottom" class="detail">
       <!-- Sticky footer 布局 -->
       <div class="detail-wrap">
         <div class="ditail-main clearfix">
           <p class="title">{{ seller.name }}</p>
           <!-- 评分星星区域 -->
           <div class="star-wrap">
             <v-star :size="48" :score="seller.score"></v-star>
           </div>
           <!-- 优惠详情区域 -->
           <div class="discount-detail-title">
             <div class="line"></div>
             <h3 class="text">优惠信息</h3>
             <div class="line"></div>
           </div>
           <ul v-if="seller.supports" class="supports">
             <li class="support-item" v-for="(item,i) in seller.supports"
             :key="item.bulletin">
              <span class="icon" :class="classMap[seller.supports[i].type]"></span>
              <span class="text">{{ seller.supports[i].description }}</span>
             </li>
           </ul>
            <!-- 商家公告区域 -->
           <div class="seller-bulletin-title">
             <div class="line"></div>
             <h3 class="text">商家公告</h3>
             <div class="line"></div>
           </div>
           <p class="bulletin-detail">{{ seller.bulletin }}</p>

         </div>
       </div>
       <div class="detail-close" @click="closeDetail">
         <i class="icon-close"></i>
       </div>
    </mt-popup>
    </div>
</template>

<script>
import star from "../star/star";
export default {
  data() {
    return {
      popupflag: false,
      // 优惠图标的数组
      classMap: ["decrease", "discount", "special", "invoice", "guarantee"]
    };
  },
  methods: {
    openDetail() {
      this.popupflag = true;
    },
    closeDetail() {
      this.popupflag = false;
    }
  },
  props: ["seller"],
  components: {
    "v-star": star
  }
  // created() {
  //   this.classMap = ["decrease", "discount", "special", "invoice", "guarantee"];
  // }
};
</script>
<style lang='less' scoped>
@import "../../common/css/common.less";

@header-font-color: rgb(255, 255, 255);

.header-container {
  height: 134px;
  // 去除图片和文字之间的空白字符
  // font-size: 0;
  position: relative;
  overflow: hidden;
  color: @header-font-color;
  background-color: rgba(7, 17, 27, 0.5);
  // header主体
  .content-wrapper {
    position: relative;
    padding: 24px 12px 18px 24px;
    height: 64px;
    .avatar {
      width: 64px;
      height: 64px;
      border-radius: 4px;
    }
    .support-count {
      position: absolute;
      height: 24px;
      padding: 0 8px;
      right: 12px;
      bottom: 10px;
      background-color: rgba(0, 0, 0, 0.2);
      border-radius: 7px 8px;
      .font-style(10px,24px,100);
      .icon-keyboard_arrow_right {
        line-height: 24px;
        margin-left: 2px;
      }
    }
    .content {
      margin: 2px 0 0 16px;
      display: inline-block;
      .title {
        margin-bottom: 8px;
        .brand {
          display: inline-block;
          width: 30px;
          height: 18px;
          margin-right: 6px;
          vertical-align: top;
          background-size: 30px 18px;
          .bg-image("brand");
        }
        .name {
          .font-style(16px,18px,bold);
        }
      }
      .description {
        margin-bottom: 10px;
        .font-style(10px,12px,100);
      }
      .support {
        .text {
          .font-style(10px,12px,100);
        }
        .icon {
          display: inline-block;
          width: 12px;
          height: 12px;
          vertical-align: bottom;
          margin-right: 4px;
          background-size: 12px 12px;
          &.decrease {
            .bg-image("decrease_1");
          }
          &.discount {
            .bg-image("discount_1");
          }
          &.guarantee {
            .bg-image("guarantee_1");
          }
          &.invoice {
            .bg-image("invoice_1");
          }
          &.special {
            .bg-image("special_1");
          }
        }
      }
    }
  }
  // 公告栏
  .bulletin {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    position: relative;
    height: 28px;
    line-height: 28px;
    padding: 0 22px 0 12px;
    background-color: rgba(7, 17, 27, 0.2);
    .bulletin-icon {
      .bg-image("bulletin");
      display: inline-block;
      vertical-align: top;
      margin-top: 8px;
      font-size: 12px;
      width: 22px;
      height: 12px;
      background-size: 22px 12px;
    }
    .bulletin-description {
      .font-style(10px,28px,100);
      vertical-align: top;
      margin: 0 4px;
    }
    .icon-keyboard_arrow_right {
      position: absolute;
      right: 12px;
      font-size: 10px;
      line-height: 28px;
    }
  }
  // 模糊背景
  .background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(10px);
    img {
      width: 100%;
      height: 100%;
    }
  }
  // 弹出层样式
  .detail {
    width: 100%;
    height: 100%;
    background-color: rgba(7, 17, 27, 0.8);
    overflow: auto;
    .detail-wrap {
      min-height: 100%;
      width: 100%;
      text-align: center;
      .ditail-main {
        width: 100%;
        margin-top: 64px;
        padding-bottom: 64px;
        .title {
          .font-style(16px,16px,700);
        }
        .star-wrap{
          margin-top: 16px;
          margin-bottom: 28px;
        }
        .discount-detail-title,.seller-bulletin-title{
          display: flex;
          width: 80%;
          margin:0 auto 24px auto;
          .line{
            flex: 1;
            position: relative;
            top: -6px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.4);
          }
          .text{
            .font-style(14px,14px,700);
            padding: 0 12px;
          }
        }
        .supports{
          margin: 0 58px 28px;
          .support-item{
            margin-bottom: 12px;
            text-align: left;
            font-size: 0;
            &:last-child{
              margin-bottom:0;
            }
            .icon{
              display: inline-block;
              margin-right: 6px;
              width: 16px;
              height: 16px;
              background-size: 16px 16px;
              &.decrease {
                .bg-image("decrease_2");
              }
              &.discount {
                .bg-image("discount_2");
              }
              &.guarantee {
                .bg-image("guarantee_2");
              }
              &.invoice {
                .bg-image("invoice_2");
              }
              &.special {
                .bg-image("special_2");
              }
            }
            .text{
              vertical-align: top;
              .font-style(12px, 16px, 200)
            }
          }
        }
        .bulletin-detail{
          text-align: left;
          margin: 0 58px 28px;
          .font-style(12px,24px,200)
        }
      }
    }
    .detail-close {
      position: relative;
      width: 32px;
      height: 32px;
      margin: -64px auto 0 auto;
      clear: both;
      font-size: 32px;
    }
  }
}
</style>
